/*
  ID: nemokin1
  PROG: checker
  LANG: C++
*/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
 
using namespace std;
 
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=b;--i)
#define FOREACH(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define ALL(c) (c).begin(),(c).end()
 
#define debug(x) cerr<< #x << " = " << (x) << "\n";
#define debugv(v) cerr << #v << " = "; FOREACH(it,v) cerr << *it <<","; cerr << "\n";
#define SIZE(a)  (int(a.size()))
 
template<typename T> inline void checkMax(T& a, T b) {if (b>a) a=b;}
template<typename T> inline void checkMin(T& a, T b) {if (b<a) a=b;}
 
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef long double ld;
const int INF = 1000000000;

bool visited[20];
int vs[20];
int N;
int cnt = 0;
bool goon = true;
int nprint = 0;

void dfs(const int& row, const int& limit)
{
    if(row == N){
	cnt++;
	if(N > 6 && vs[0] < N/2) cnt++;
	if(nprint++ < 3){
	    for(int i = 0; i < N-1; i++)
		cout << vs[i]+1 << " ";
	    cout << vs[N-1]+1 <<endl;
	}
	return;
    }
    for(int i = 0; i < limit; i++){
	if(visited[i] == 1) continue;
	int t;
	for(t = 0; t < row; t++){
	    if((vs[t]-i) == (row-t) || (vs[t]-i) == -(row-t)) break;
	}
	if(t != row) continue;
	visited[i] = 1;
	vs[row] = i;
	dfs(row+1, N);
	visited[i] = 0;
    }
}
	
int main() {
    freopen("checker.in","r",stdin);freopen("checker.out","w",stdout);
    cin >> N;
    memset(visited,0,sizeof(visited));
    dfs(0,N>6?(N+1)/2:N);
    cout << cnt <<endl;
    exit(0);
}
